package cn.doitedu.demo5;

import cn.doitedu.demo1.UserEvent_1;
import com.alibaba.fastjson.JSONObject;
import org.apache.flink.api.common.functions.RuntimeContext;
import org.apache.flink.util.Collector;

public class Rule2_Calculator implements RuleCalculator{

    JSONObject message  = new JSONObject();

    @Override
    public void init(RuntimeContext runtimeContext) {
        System.out.println("rule-002,我被初始化了");
    }

    @Override
    public void calc(UserEvent_1 eventBean, Collector<String> out) {
        // 再处理规则2
        if(eventBean.getEvent_id().equals("W")){
            message.put("user_id",eventBean.getUid());
            message.put("hit_time",eventBean.getTimestamp());
            message.put("rule_id","rule-002");

            out.collect(message.toJSONString());
        }

    }
}
